package category

import (
	"net/http"

	"gitee.com/zoneaurora/shop/internal/common"
	"gitee.com/zoneaurora/shop/internal/model"
	"github.com/gin-gonic/gin"
)

func GetCategories(c *gin.Context) {
  db := common.DB()
  var categories []model.Category
  if err := db.Limit(4).Find(&categories).Error; err != nil {
		common.JSON(c, http.StatusInternalServerError, "分类获取失败", nil)
    return
  }
  common.JSON(c, http.StatusOK, "分类获取成功", categories)
}
